<template>
  <header class="header">
      <h1>小黑记事本</h1>
      <input v-model.trim="todoName" placeholder="请输入任务" class="new-todo" />
      <button class="add" @click="add">添加任务</button>
    </header>
</template>

<script>
export default {
    name: 'TodoHeader',
    data() {
        return {
            todoName: ''
        }
    },
    methods: {
        add() {
            // 先子传父 再清空
            this.$emit('add', this.todoName)
            this.todoName = ''
        }
    }
}
</script>

<style>

</style>